package com.pearadmin.pro.modules.fnc.rest;

import com.pearadmin.pro.modules.fnc.domain.ScrmFncInfo;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import  com.pearadmin.pro.modules.fnc.domain.ScrmFncInfo;
import  com.pearadmin.pro.modules.fnc.param.ScrmFncInfoRequest;
import  com.pearadmin.pro.modules.fnc.service.ScrmFncInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 财务-收支明细Controller
 *
 * @author ChenJIan
 * @date 2021-09-25
 */
@Api(tags = {"财务-收支明细"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"fnc/fncInfo")
public class ScrmFncInfoController extends BaseController
{
    @Resource
    private ScrmFncInfoService scrmFncInfoService;

    /**
     * 查询财务-收支明细列表
     *  @param request 查询参数
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "财务-收支明细列表")
    @ApiOperation(value = "财务-收支明细列表")
    public Result<ScrmFncInfo> list(ScrmFncInfoRequest scrmFncInfoRequest)
    {
        return success(scrmFncInfoService.page(scrmFncInfoRequest));
    }


    /**
     * 新增保存财务-收支明细
     * @param scrmFncInfo 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增财务-收支明细")
    @ApiOperation(value = "新增财务-收支明细")
    public Result save(@RequestBody ScrmFncInfo scrmFncInfo)
    {
        return auto(scrmFncInfoService.saveOrUpdate(scrmFncInfo));
    }

    /**
     * 查询财务-收支明细详情
     *
     * @param id 财务-收支明细ID
     * @return 财务-收支明细
     */
    @GetMapping("/selectById")
    @Log(title = "查询财务-收支明细详情")
    @ApiOperation(value = "查询财务-收支明细详情")
    public Result<ScrmFncInfo> selectById(@RequestParam Long id)
    {
        return success(scrmFncInfoService.selectScrmFncInfoById(id));
    }



    /**
     * 修改保存财务-收支明细
     * @param scrmFncInfo 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改财务-收支明细")
    @ApiOperation(value = "修改财务-收支明细")
    public Result update(@RequestBody ScrmFncInfo scrmFncInfo)
    {
        return auto(scrmFncInfoService.saveOrUpdate(scrmFncInfo));
    }


    /**
     * 删除保存财务-收支明细
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除财务-收支明细")
    @ApiOperation(value = "删除财务-收支明细")
    public Result remove(@RequestParam Long id)
    {
        return auto(scrmFncInfoService.removeById(id));
    }

    /**
    * 批量删除财务-收支明细
    * @param ids 批量删除
    * @return {@link Result}
    */
    @DeleteMapping("removeBatch")
    @Log(title = "批量删除财务-收支明细")
    @ApiOperation(value = "批量删除财务-收支明细")
    public Result removeBatch(@RequestParam List<Long> ids){
        return auto(scrmFncInfoService.removeByIds(ids));
    }

}
